package cn.outmaneuver.outman.demo.dynamic.database.controller;
/**
 * Copyright 2023-2023 by dym. All Rights Reserved.
 */

import cn.outmaneuver.outman.demo.dynamic.database.config.DynamicDataSourceContextHolder;
import cn.outmaneuver.outman.demo.dynamic.database.service.DemoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * DemoController
 * <p> </p>
 *
 * @author dym
 * @date 2023/11/03
 * @version 1.0
 */
@RestController
@RequestMapping("/demo")
public class DemoController {
    @Autowired
    private DemoService demoService;

    @RequestMapping("/checkDatabase")
    public String checkDatabase(String orgId){
        if("41999A".equals(orgId)){
            DynamicDataSourceContextHolder.setDataSourceType("41999A");
        }
        if("41999B".equals(orgId)){
            DynamicDataSourceContextHolder.setDataSourceType("41999B");
        }
        return demoService.checkDataBase(orgId);
    }
}
